#ifndef __CHARACTER_DEVICE_DRIVE_LED_H
#define __CHARACTER_DEVICE_DRIVE_LED_H
#include "led_config.h"

#ifdef CHARACTER_DEVICE
#define NAME_MAX 64
struct object
{
    char       name[NAME_MAX];                       /**< name of kernel object */
    int type;                                        /**< type of kernel object */
    int flag;                                        /**< flag of kernel object */
};
typedef struct object *object_t;                  /**< Type for kernel objects. */

enum device_class_type
{
    Device_Class_Char = 0,                           /**< character device */
};

typedef struct device *device_t;
struct device_ops
{
    int  (*init)   (device_t dev);
    int  (*open)   (device_t dev, int oflag);
    int  (*close)  (device_t dev);
    int  (*read)   (device_t dev, int pos, void *buffer, int size);
    int  (*write)  (device_t dev, int pos, const void *buffer, int size);
    int  (*control)(device_t dev, int cmd, void *args);
};

struct device
{   
    struct object           parent;                   /**< inherit from rt_object */
    enum device_class_type  type; 
    int                     flag;                     /**< device flag */
    int                     open_flag;                /**< device open flag */
    int                     ref_count;                /**< reference count */
    int                     device_id;
    const struct device_ops *ops;
    void                    *user_data;
};

enum led_color
{
    HAL_LED_NONE = 0,
    HAL_LED_RED,
    HAL_LED_BLUE,
    HAL_LED_GREEN,
};
struct led_user_register_ops
{
    int (*init)(void);
    int (*led_on)(enum led_color color);
    int (*led_off)(enum led_color color);
};
device_t get_led_device(void);
void register_led_device(const char *name ,struct led_user_register_ops *ops);
void led_demo(void);
#endif


#endif